package dawn.net;

import java.util.concurrent.atomic.AtomicInteger;

import dawn.core.dispatch.SingleListenerDispathcer;

/**
 * rpc请求的管理器，单例实现
 * @author huangxiao
 */
public class RpcManager extends SingleListenerDispathcer<Integer, RpcResponse> {

	/**
	 * 自增的序列
	 */
	private AtomicInteger sequence = new AtomicInteger(1);

	/**
	 * 自增的序列，它是线程安全的
	 * @return
	 */
	public int nextSequenceId() {
		return sequence.getAndIncrement();
	}

	private static RpcManager ins = new RpcManager();

	public static RpcManager getInstance() {
		return ins;
	}
}
